﻿using System.Drawing;
using System.Runtime.Serialization;
using System.IO;

namespace MediaController.Server.Core.DataContracts
{
    [DataContract]
    public class FileContract
    {
        /// <summary>
        /// Get the full file name path
        /// </summary>
        [DataMember(Name = "FullName", IsRequired = true)]
        public string FullName { get; private set; }

        /// <summary>
        /// Get the file name
        /// </summary>
        [DataMember(Name = "FileName", IsRequired = true)]
        public string FileName { get; private set; }

        /// <summary>
        /// Get the associated file icon
        /// </summary>
        [DataMember(Name = "Icon", IsRequired = true)]
        public Icon Icon { get; private set; }

        public FileContract(string fileName)
        {
            FullName = fileName;
            FileName = Path.GetFileName(fileName);

            Icon = Icon.ExtractAssociatedIcon(fileName);
        }

        public override string ToString()
        {
            return FullName;
        }
    }
}